﻿using Jay.Sc2.Bof.Lib.State;

namespace Jay.Sc2.Bof.Lib.Action.Zerg
{
	public class ActionProduceHive : ActionProduceZerg
	{
		public static ActionProduceHive Instance = new ActionProduceHive();
		private ActionProduceHive() : base(100, 200, 150, 0) { }
		public override void Execute(IBuildOrder bo)
		{
			ZergState state = bo.State as ZergState;
			base.Execute(bo);
			state.Lair.Upgrade++;
			state.Hive.Building++;
			bo.AddAction(state.Time + BuildTime, new ActionGeneric("ActionSpawnHive", (ActionGeneric.ActionExecuteDelegate)delegate(IBuildOrder ibo)
			{
				ZergState ibostate = ibo.State as ZergState;
				state.Hive.Built();
				state.Lair.Count--;
				state.Lair.Upgrade--;
			}));
		}
		public override bool HaveTechnology(IBuildOrder bo)
		{
			ZergState state = bo.State as ZergState;
			return state.InfestationPit.Count > 0;
		}
		public override bool IsInvalid(IBuildOrder bo)
		{
			ZergState state = bo.State as ZergState;
			return base.IsInvalid(bo) || state.InfestationPit.Total == 0 || state.Lair.Total == 0;
		}
		public override int AvailableProducer(IBuildOrder bo)
		{
			ZergState state = bo.State as ZergState;
			return state.Lair.AvailableForUpgrade;
		}
		private IAction[,] m_Requirements;
		public override IAction[,] Requirements
		{
			get
			{
				if (m_Requirements == null)
					m_Requirements = new IAction[,] { { ActionProduceInfestationPit.Instance } };
				return m_Requirements;
			}
		}
		private IAction[,] m_Inputs;
		public override IAction[,] Inputs
		{
			get
			{
				if (m_Inputs == null)
					m_Inputs = new IAction[,] { { ActionProduceLair.Instance } };
				return m_Inputs;
			}
		}
	}
}
